﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;

namespace OnlineDovizOtomasyonu
{
    public partial class Sablon : System.Web.UI.MasterPage
    {
        Fonksiyon Sistem = new Fonksiyon();
        protected void Page_Load(object sender, EventArgs e)
        {
            OrtaBolunmusPanel.Panes.GetByName("OrtaSolPanel").Size = 250;
            
            if (string.IsNullOrEmpty((string)Session["webingAdminID"]))
            {

            }
            else
            {
                SqlConnection con = Sistem.baglan();
                SqlCommand komut = new SqlCommand();
                komut.Connection = con;
                komut.CommandText = "SELECT * FROM TBLKULLANICI WHERE ID=" + Convert.ToInt32(Session["webingAdminID"]);
                SqlDataReader dr = komut.ExecuteReader();
                while (dr.Read())
                {
                    lblKullanıcı.Text = "Hoşgeldin "+ dr["ADI"].ToString();
                    lblBilgiDuzenle.NavigateUrl = "sistem.aspx?kk=" + MD5Olustur(dr["ID"].ToString()) + "?ka=" + MD5Olustur(dr["ADI"].ToString());
                }
            }
        }

        public string MD5Olustur(string input)
        {
            MD5 md5Hasher = MD5.Create();
            byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder sBuilder = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }
            return sBuilder.ToString();
        }
    }
}